#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2020/9/7 10:16
# @Author : 吴敬超
# explain:
import pandas as pd
import numpy as np

#
# data_arr = []
# data = iter_files(dir,speakers)
# for k,v in data.items():
#     data_arr.append([k,v])
# # print(data_arr)
#
# np_data = np.array(data_arr)
#
# ##写入文件
# pd_data = pd.DataFrame(np_data,columns=['filename','gender'])
# print(pd_data)
# pd_data.to_csv('pd_data.csv')
#
#


x = [1, 2, 3]
np_data = np.asarray(x)

##写入文件
pd_data = pd.DataFrame(np_data)
# print(pd_data)
pd_data.to_csv('pd_data.csv')

'''第一种写法：当值都是list类型的数据'''
data1 = {'A': range(3), 'B': list("abc"), 'C': ['red', np.NaN, 'yellow']}
df1 = pd.DataFrame(data1)
'''第二种写法：当值为string类型的数据，此时需要加上 index=[0] 因为pandas 的dataframe需要一个可迭代的对象'''
# data2 = {'姓名': 'fuhang', '性别': '男', '昵称': '那时的吻真香'}


list1 = ['physics', 'chemistry', 'tom', 'chegn']
list2 = [1, 2, 3, 4 ]
list3 = ["a", "b", "c", "d"]
data3 = {'A': list1, 'B': list2, 'C':list3}
df3 = pd.DataFrame(data3)

data2 = {'fuhangsgf', '男', 'dad那时的daf吻真香'}
datanp=np.asarray(data2)
# df2 = pd.DataFrame(datanp)
# print(df2)
# df1.to_csv('Result1.csv', index=None, mode='ab', header=False)
# df2.to_csv('Result2.csv', index=None, mode='ab', header=False)
df3.to_csv('Result3.csv', index=None, mode='ab', header=False)
